<!DOCTYPE html>

<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>登录</title>
    <link rel="stylesheet" href="./plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="./plugins/layui/css/myPage.css">
    <link rel="stylesheet" href="./css/login.css">
</head>

<body class="beg-login-bg">
<div class="beg-login-box layui-anim layui-anim-scale" >
    <header>
        <h1>智运宝TMS</h1>
    </header>
    <div class="beg-login-main">
        <form class="layui-form" method="post">
            <div class="layui-form-item">
                <label class="beg-login-icon">
                    <i class="layui-icon">&#xe612;</i>
                </label>
                <input type="text" name="yhm" lay-verify="userName"  style="height: 35px;width: 230px" autocomplete="off" placeholder="这里输入登录名" class="layui-input" id="user">
            </div>
            <div class="layui-form-item">
                <label class="beg-login-icon">
                    <i class="layui-icon">&#xe642;</i>
                </label>
                <input type="password" name="mima" lay-verify="password"  style="height: 35px;width: 230px"  autocomplete="off" placeholder="这里输入密码" class="layui-input" id="pswd">
            </div>
            <div class="layui-form-item">

                    <label class="forgetPsw" style=" padding-left: 83% ;white-space:nowrap"  id="forgetPsw" >
                     忘记密码?
                    </label>
            </div>
            <div class="layui-form-item">

            <div class="beg-pull-center">
                <button class="layui-btn layui-btn-primary" lay-submit lay-filter="login" style="width: 80px;height: 38px;"  id="login">
                    登  录
                </button>
            </div>
            <div class="beg-clear"></div>
        </div>
        </form>
    </div>


    <footer>
        <p>杭州长禧智慧物流科技有限公司</p>
        <p>推荐使用谷歌Chrome浏览器</p>
    </footer>
</div>
<div id="version" style="color:white;position: absolute;left: 0;bottom: 0"></div>
<script src="./js/config.js"></script>
<script src="./plugins/layui/layui.js"></script>
<script src="./js/tools.js"></script>
<script src="./js/jquery.js"></script>
<script src="./js/jquery.md5.js"></script>

<script>
    layui.use(['layer', 'form'], function() {
        var layer = layui.layer,
            $ = layui.jquery,
            form = layui.form;
        $(document.body).css({
            "overflow-x":"hidden",
            "overflow-y":"hidden"
        });
        $("#version").html(version);
        form.on('submit(login)',function(data){
            //登陆请求
            data.field.mima = $.md5(data.field.mima);
            console.log(data.field);
            $.ajax({
                url: contextPath+"/loginUser" ,
                type: "POST",
                contentType:"application/json;charset=utf-8",
                dataType:"json",
                data: JSON.stringify(data.field) ,
                success: function(res) {
                    if(res.message == "登录成功！"){
                        window.location.href="index.html";
                    }else{
                        layer.msg(res.message);
                    }
                }
            });
            return false;
        });

        $('#forgetPsw').click(function () {
            layer.open({
                cancel: function(index, layero){
                    var faIndex = index;
                    layer.confirm('确定要关闭么?未保存的信息将会丢失!', {icon: 3, title:'提示'}, function(index){
                        //do something
                        layer.close(index);
                        layer.close(faIndex);
                    });
                    return false
                },
                type: 2,
                title: '忘记密码',
                maxmin: true,
                shadeClose: false, //点击遮罩关闭层
                area : ['30%' , '40%'],
                content: ['./forgetPsw.html','no'],
                end:function(){
                    // window.location.reload();
                }
            });
        });
    });

</script>
</body>

</html>